<template>
  <a-modal title="采购统计" style="top: 100px;" :visible="isShow" width="600px" @ok="handleOk" @cancel="handleCancel"
    okText="查询">
    <IForm :formFrame="frame" class="form-container" :formData.sync="form"></IForm>
    <span>采购数量 {{info.a}} 个</span></br>
    <span>采购总额 {{info.b}} 元</span></br>
    <span>采购品种 {{info.c}} 个</span></br>
  </a-modal>
</template>
<script>
  import IForm from "@/components/IForm"

  export default {
    components: {
      IForm
    },
    props: {
      isShow: {
        type: Boolean
      }
    },
    computed: {
      frame() {
        return [
          {
            title: '创建时间(始)',
            key: 'created_start_at',
            type: 'date',
            showTime: false,
            required: true,
          },
          {
            title: '创建时间(终)',
            key: 'created_end_at',
            type: 'date',
            showTime: false,
            required: true,
          },
          {
            title: '采购员',
            key: 'admin_id',
            type: 'select',
            span: 12,
            options: this.admin_list
          },
          {
            title: '商品',
            key: 'key',
            tips: '填入完全匹配的商品名称'
          },
      
        ]
      }
    },
    data() {
      return {
        form: {
         
        },
        itemTotal: 0,
        info:{
          a: 0,
          b: 0,
          c: 0,
        },
        admin_list: [],
        admin_id: undefined,
      }
    },
    watch: {

    },
    mounted () {
      this.$http.get('/storage_admin_list').then(res => {
        this.admin_list = res.data.list
        this.admin_list = this.admin_list.map(item => {
          return {
            title: item.name,
            value: item.admin_id
          }
        })
      })
    },
    methods: {
      handleOk() {
        this.$http.post('/storage_buy/total', this.form).then(res => {
           this.info = res.data
        })
      },

      handleCancel() {
        this.$emit('hide')
      }
    }
  }
</script>
<style lang="scss" scoped>
  .tips {
    color: gray;
    font-size: 80%;
  }
</style>
